Folder Emblems 0.6
(c) 2010 JCC
http://blog.lilaetleloup.com
License: GPL
This is a hack to:
* add sort of an "emblem" feature to the folders in KDE4.
* simulate the "folder.jpg" functionnality of Windows XP (i.e. assign as icon to
the directory an image present within itself)
Both functionnalities are available through a "service menu", i.e. you can
right-click a folder, then choose "Actions", then one of the four menu entries
created by the installation of the .desktop file:
* Add emblem
* Add emblem (recursive)
* Apply folder image
* Apply folder image (recursive)
You can also right click on any image within a folder, then choose the action
"Set as folder icon" in order to apply the selected image as the folder icon.
Pre requisites
--------------
This software requires ImageMagick (package imagemagick in Mandriva, or
the equivalent for your distro)
If you want to turn on size optimization of the generated folder icons (see
below) then you will need one of advpng (package advancecomp), pngcrush or
optipng.
Emblem feature
--------------
It allows you to select an icon, and add it to the normal icon folder of the
selected folder. New folder icons are generated and assigned to the directory.
It works through the use of a KDE Service menu (right click on the directory,
then choose "Actions", then "Add emblem"). It can do it recursively.
"folder.jpg" feature (folder image)
-----------------------------------
It allows you to assign to a directory (and its sub-directories if called
recursively) an image which is stored within, as an icon.
Despite its name, any image name will do it.
If the folder image is not square, then applying it as a folder icon would
strech it. In order not to stretch the image, a new image (square, with a
transparent background) will be generated in the directory. The resulting
image will be named after the original image. For example, if the image is
folder.jpg, folder.jcc.png will be generated.
Of course if the image is square it will be used as is.
Note 1: due to a bug in KDE (at least in 4.4.3), you cannot use hidden images as
folder icons (for example .folder.png would be nice, but won't work).
Note 2: if you want to turn on size optimization of the generated folder.jcc.png
then you will need one of advpng (package advancecomp), pngcrush or optipng
Command line
------------
The software comes with emblem.sh, a program that can also be called from the
command line.
Usage
-----
Show this help text and exit:
emblem.sh --help
1. Add an emblem to a directory
emblem.sh [--nodialog] [[--recursive] [--progressbar]] [--local] [--notify]
<target folder> [icon file name]
when the icon file name is not provided, it will be asked to the user
interactively.
2. Apply to a directory one of its images as icon:
emblem.sh [--nodialog]
[[--recursive] [--progressbar]]
--folderimg (<image file name>|--ask)
[--defaultfolderimg <default image name>

[--optimize]
[--notify]
<target folder>
3. Apply an image as icon to its directory
emblem.sh --setasfoldericon <image file name>
Options:
--help show this help text and exit
--nodialog do not fire kdialog in case of an error
--recursive perform the action on the folder <target folder>
and all of the folders contained witin
--local save the generated icon as <target folder>/folder.png
instead of creating it ~/.config/jcc/emblems
(useful to move directories between machines without
losing their icon)
--folderimg use <image file name> as the icon to be set
(e.g. folder.jpg)
if used with --ask, the user will be asked interactively
--defaultfolderimg default image name to be used in the dialog box when
asking the user. Implies --folderimg --ask.
--optimize optimize generated images for non square folder icons
--setasfoldericon allows to set the image given as a parameter as its
containing directory icon
--notify send notifications to the desktop so that passive popups
can be displayed when the job is over (the error
messages are also displayed this way instead of dialogs)
Install
-------
To install, copy the .desktop files to the kde4 service menus directory
(e.g. /usr/share/kde4/services/ServiceMenus/emblem.desktop
or better ~/.kde4/share/kde4/services/)
and copy emblem.sh to your bin directory
(e.g. ~/bin/emblem.sh)
Note: if /home/<user>/bin does not exist, then create it.
emblem.sh needs the "composite" command from ImageMagick. This package must be
installed on your machine.
To configure the parameters, please edit directly emblem.sh.
In particular, you should edit BASE_FOLDER_ICON to point to the default
folder icon you are using.
You can also change the location of emblem.sh, but you'll have to modify
the emblem.desktop file to point to the right place.
Note: the generated folder emblem icons are stored in ~/.config/jcc/emblems/
[/quote]
Ratings & Comments
16 Comments
Hello! I just wondered if it would be possible to modify the script to add the emblems to the bottom right corner of the base folder to match the emblems in the new oxygen icons in KDE 4.7.
You can edit the script to change the position and size of the emblem. Sorry it is not configurable more easily.
OK Great. Thanks. Just a matter of changing GRAVITY to southeast then.
Good job. but I wish I could also change the icons of files within folders. For example putting the covers of films in the archives
I'd like that too, unfortunately, this is not currently supported by KDE
./emblem.sh folderemblems-0.3 /usr/share/icons/oxygen/22x22/actions/acrobat.png folderemblems-0.3/emblem.sh: line 92: printf: scalable: недопустимое число Using default kde theme icon for folder.png mktemp: failed to create file via template `/home/jura/tmp/tmp.XXXXXXXXXX': Нет такого файла или каталога composite: unable to open image `/usr/share/icons/default.kde4/064x064/places/folder.png': /usr/lib/ImageMagick-6.6.1/modules-Q16/coders/png.la @ error/blob.c/OpenBlob/2489. composite: unable to open image `/usr/share/icons/default.kde4/064x064/places/folder.png': @ error/blob.c/OpenBlob/2489. composite: unable to open file `/usr/share/icons/default.kde4/064x064/places/folder.png' @ error/png.c/ReadPNGImage/3014. composite: missing an image filename `' @ error/composite.c/CompositeImageCommand/1607. Error creating the icon
thanks for the report. version 0.4 will fix these problems.
Will this work with Dropbox or Kfilebox, and show the sync-ing/ed emblems as Gnome's Nautilus does?
It won't. First it works only on directories, then it is more a hack than a real emblem support. In fact icons are generated for the folder when you assign it an "emblem". I don't know/use dropbox, so do not know how the emblems are generated there.
This is great! This should be a standard part of the KDE SC distros.
thanks a lot!
This is a great addition!!!! It works perfectly well. Thanks a lot.
I forgot: Would it be possible to add an option to set an emblem recursively? That would allow me to differentiate the different partitions which each folder belongs to.
thanks! indeed this would be a good idea. to keep it simple, I could add a second menu entry "add emblem recursively", what do you think?
That's exactly what I thought.
published today!